package frame.options.simulation.results.sdn.graphical;

import model.components.links.link.Link;
import model.components.nodes.node.Node;
import edu.uci.ics.jung.algorithms.layout.Layout;
import edu.uci.ics.jung.visualization.VisualizationViewer;
import edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse;
import edu.uci.ics.jung.visualization.decorators.EdgeShape;
import edu.uci.ics.jung.visualization.renderers.Renderer.VertexLabel.Position;
import frame.options.simulation.results.ResultsFrame;

@SuppressWarnings("serial")
public class SdnNetworkViewer extends VisualizationViewer< Node, Link >
{
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public SdnNetworkViewer( Layout< Node, Link > layout, ResultsFrame resultsFrame )
	{
		super( layout );
		
		try
		{
			//this.getRenderContext().setVertexIconTransformer( new SdnNodeIconTransformer() );
			this.getRenderContext().setVertexFillPaintTransformer( new SdnNodeColorTransformer() );
			
			this.getRenderContext().setVertexLabelTransformer( new SdnNodeLabelTransformer() );
			this.getRenderer().getVertexLabelRenderer().setPosition( Position.AUTO );
			
			this.getRenderContext().setEdgeShapeTransformer( new EdgeShape.CubicCurve() );
			this.getRenderContext().setEdgeDrawPaintTransformer( new SdnLinkColorTransformer() );
			
	        DefaultModalGraphMouse< Node, Link > defaultModalGraphMouse = new DefaultModalGraphMouse< Node, Link >();
	        defaultModalGraphMouse.setMode( DefaultModalGraphMouse.Mode.TRANSFORMING );
	        defaultModalGraphMouse.add( new SdnNetworkPlugin( resultsFrame ) );
	        
	        this.addKeyListener( defaultModalGraphMouse.getModeKeyListener() );
	        this.setGraphMouse( defaultModalGraphMouse );
		}
		catch( Exception e ){}
	}
	
}
